package utils

import (
	"fmt"
	"github.com/google/uuid"
	"strings"
)

const (
	SALT = "cdsdp"
)

func GetUUID() string {
	uuidn := uuid.New()
	return uuidn.String()
}

func DpUUIDPath(uuid, pathType, fileext string) string {
	salt := "xiaoda"
	random := strings.ToLower(GetRandomString(6))
	hash := Md5(pathType + uuid + salt)
	if fileext != "" && fileext[0:1] == "." {
		fileext = fileext[1:]
	}
	uPath := fmt.Sprintf("dp/%s/%s/%s/%s_%s.%s", pathType, hash[0:2], hash[2:4], uuid, random, fileext)
	return uPath
}

func GetShortUUID() string {
	s := GetUUID()
	return strings.Replace(s, "-", "", -1)
}
